package com.example.springboot.service.impl;

import com.example.springboot.pojo.Goods;
import com.example.springboot.service.LocationService;
import com.example.springboot.mapper.LocationMapper;
import com.example.springboot.pojo.Location;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class LocationServiceImpl implements LocationService {
    @Autowired
    private LocationMapper locationMapper;
    @Override
    public void create(Location location) {
        locationMapper.create(location);
    }
    @Override
    public void delete(Integer id) {
        locationMapper.delete(id);
    }
    @Override
    public List<Location> findAll() {
        return locationMapper.findAll();
    }
    @Override
    public Location findById(Integer id) {
        return locationMapper.findById(id);
    }
    @Override
    public void update(Location location) {
        locationMapper.update(location);
    }
    @Override
    public List<Location> findByName(String locationname){
        return locationMapper.findByName( locationname);
    }
    @Override
    public PageInfo<Location> selectPage(Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<Location> list = locationMapper.findAll();
        return PageInfo.of(list);
    }

    @Override
    public void deleteBatch(List<Integer> ids) {
        for (Integer id : ids) {
            locationMapper.delete(id);
        }
    }

}
